﻿using System;

namespace BF3StatsNetApi.BLL
{
    /// <summary>
    /// 
    /// </summary>
    class Utility
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="unixTimeStamp"></param>
        /// <returns>Returns a <see cref="DateTime"/> object containing the date and time.</returns>
        public static DateTime? UnixTimeStampToDateTime(object unixTimeStamp)
        {
            if (unixTimeStamp != null)
            {
                // Unix timestamp is seconds past epoch
                DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                return dtDateTime.AddSeconds(double.Parse(unixTimeStamp.ToString())).ToLocalTime();
            }

            return null;
        }
    }
}
